#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int sum = 0;
	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		int x;
		cin>>x;
		if(x>0) sum += x;
		else 
		{
			if(sum>=-x) sum += x;
			else ans++;
		}
	}
	cout<<ans<<endl;
}
